@echo off

echo 🔍 检查Django后端状态...

:: 检查Django后端是否运行
curl -s -o nul -w "%%{http_code}" http://localhost:8000/api/health/ >response_code.tmp 2>nul

if exist response_code.tmp (
    set /p response_code=<response_code.tmp
    del response_code.tmp
    
    if "!response_code!"=="200" (
        echo ✅ Django后端运行正常 ^(HTTP !response_code!^)
        
        :: 测试登录接口
        echo 🔐 测试登录接口...
        curl -s -X POST -H "Content-Type: application/json" -d "{\"username\":\"test\",\"password\":\"test123\"}" http://localhost:8000/api/auth/login/
        echo.
        echo ✅ 登录接口测试完成
    ) else (
        echo ❌ Django后端响应异常 ^(HTTP !response_code!^)
    )
) else (
    echo ❌ Django后端未运行或无法访问
    echo 请运行: cd d:\hmm ^&^& python manage.py runserver 8000
)

pause